import time
import os 

user = os.popen("who | awk '{ if (NR==1){print $1} }'").read().strip()
setting  = {
	'dir_path' : '/home/{}/Documents/English_words/'.format(user),
}
class utils_check:
	@staticmethod
	def get_today_time():
		#info = {}
		#priary =  time.time()
		#info['year'] = priary[0]
		#info['mon'] = priary[1]
		#info['day'] = priary[2]
		info = time.asctime().split()[:3]
		return ' '.join(info)


	@staticmethod
	def ls_dir():
		#check and create dir 
		utils_check.check_and_create(setting['dir_path'])

		files  = list(map((lambda x : x[:-2] ), os.popen("ls "+ setting['dir_path']))) 
		return files

	@staticmethod
	def check_and_create(path):
		if not os.path.exists(path) :
			os.mkdir(path)
		else:
			pass

class Write:

	@staticmethod 
	def Log(callback,argu):

		Res ="\n" + callback(argu)
		t_info = utils_check.get_today_time()
		#save
		with open(setting['dir_path']+t_info+'.html','a') as FILE:
			FILE.write(Res)



